package com.example.dormmanage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dormmanage.entity.Loss;
import com.example.dormmanage.service.impl.LossService;
import com.example.dormmanage.view.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/loss")
@Api(tags = "钥匙丢失登记管理接口")
public class LossController {

    @Autowired
    private LossService lossService;

    @GetMapping
    @ApiOperation("管理员查询钥匙丢失列表")
    public ResultView<Page> selectLossList(Integer page, Integer pageSize, Integer buildingId, String studentName){
        return lossService.selectLossList(page,pageSize,buildingId,studentName);
    }

    @PutMapping("/{lossId}/{checkStatus}")
    @ApiOperation("管理员审核")
    public ResultView<String> checkLoss(@PathVariable Long lossId, @PathVariable Integer checkStatus){
        return lossService.checkLoss(lossId,checkStatus);
    }

    @GetMapping("/student")
    @ApiOperation("学生查询钥匙丢失列表")
    public ResultView<Page> selectLossList(Integer page, Integer pageSize){
        return lossService.selectLossList(page,pageSize);
    }

    @PostMapping
    @ApiOperation("学生新增钥匙丢失记录")
    public ResultView<String> addLoss(@RequestBody Loss loss){
        return lossService.addLoss(loss);
    }

}
